import Common from '../../../common/common.js';
let common = new Common;
Page({
  data: {
    loadingShow: true,
    orderId: '', //订单id
    result: {},
    giftId: '', //礼品id
  },

  onLoad: function (options) {
    console.log(options)
    this.setData({
      orderId: options.id
    })
    console.log(getApp().globalData.orgseq);
    this.getPageData();
  },
  onShow() {},
  // 查询详情
  getPageData() {
    this.setData({
      loadingShow: true,
    })
    common.requestAjax('/api/promotion-service/v1/BonuspointConvert/queryBonuspointConvert?convertId=' + this.data.orderId, 'POST').then(res => {
      console.log(res)
      this.setData({
        loadingShow: false,
      })
      this.setData({
        result: res.data.result
      })

    }).catch(err => {
      console.log(err)
    })
  },
  confirmSendGoods() {
    wx.showModal({
      title: '提示',
      content: '发货后不可取消,是否发货？',
      success: res => {
        if (res.confirm) {
          common.requestAjax('/api/promotion-service/v1/BonuspointConvert/sendBonuspointConvert', 'POST', {
            convertIds: [this.data.orderId]
          }).then(res => {

            if (res.data.code) {
              wx.showToast({
                title: '发货成功',
                icon: 'none'
              })
              this.getPageData();
            }else{
              wx.showToast({
                title: res.data.message,
                icon: 'none'
              })
            }
          })
        }
      }
    })
  }
})